/**
 * AgaEngine (c)2011.
 * FileName:Tank.java
 */
package aga.game.tankhero;

import aga.engine.MyGameApp;
import aga.engine.R;
import aga.engine.go.Sprite;
import aga.engine.listener.ITickListener;
import aga.engine.physic.PhysicEngine;
import aga.engine.tools.GameTool;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;

/**
 * 
 * @author zhe.yangz
 */
public class Shell extends Sprite {
	//===========================================================
	//Constants
	//===========================================================


	//===========================================================
	//Fields
	//===========================================================
	public float mSpeed = 10;
	public float mAngle = 45;

    public boolean isEnemy = false;
	//===========================================================
	//Constructors
	//===========================================================
	/**
	 * @param x
	 * @param y
	 * @param angle
	 */
	public Shell (int x, int y, float angle, boolean isEnemy) {
        super(null, x, y, angle);
		
		MyGameApp myGameApp = MyGameApp.getInstance();
		Resources res = myGameApp.getResources();
		mBitmapMain = BitmapFactory.decodeResource(res, R.drawable.shell_small);
		
		mX = x;
		mY = y;
	
		mAngle = angle;

        this.isEnemy = isEnemy;

	}
	//===========================================================
	//Getter & Setter
	//===========================================================

	//===========================================================
	//Methods for/from SuperClass/Interfaces
	//===========================================================
	@Override
	public void draw(Canvas canvas) {
		if (mBitmapMain != null) {
			Matrix matrix=new Matrix();  
			matrix.postRotate(mAngle/*, mBitmapMain.getWidth()/2, mBitmapMain.getHeight()/2*/);  
			Bitmap dstbmp=Bitmap.createBitmap(mBitmapMain,0,0,mBitmapMain.getWidth(),  
					mBitmapMain.getHeight(),matrix,true);   
			
			canvas.drawBitmap(dstbmp, this.getX(), this.getY(), null);

		}
	}

	@Override
	public void tick() {
        mX += GameTool.checkAdjustX(mSpeed, mAngle);
        mY += GameTool.checkAdjustY(mSpeed, mAngle);
	}
}
